﻿using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace Panos.Utils
{
    public static class ImageExtensions
    {
        public static DateTime? GetPropertyTagDateTime(this Image image)
        {
            PropertyItem item;
            try
            {
                item = image.GetPropertyItem(0x0132);
                return image.GetPropertyItem(0x0132).GetDateTime();
            }
            catch (ArgumentException)
            {
                return null;
            }
        }

        public static Angle GetPropertyTagGpsLongitude(this Image image)
        {
            return image.GetPropertyItem(0x0004).GetAngle();
        }

        public static Angle GetPropertyTagGpsLatitude(this Image image)
        {
            return image.GetPropertyItem(0x0002).GetAngle();
        }
    }
}